home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1944 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.3 KB

  1. Path: news1.h1.usa.pipeline.com!usenet
  2. From: grantp@usa.pipeline.com(Pete)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Sockets don't work under VC++ 4.0 ?!!
  5. Date: 14 Jan 1996 11:12:59 GMT
  6. Organization: Kalevi, Inc.
  7. Message-ID: <4daofr$41b@news1.usa.pipeline.com>
  8. NNTP-Posting-Host: pipe8.h1.usa.pipeline.com
  9. X-PipeUser: grantp
  10. X-PipeHub: usa.pipeline.com
  11. X-PipeGCOS: (Pete)
  12. X-Newsreader: Pipeline USA v3.3.0
  13.  
  14. On Jan 14, 1996 00:54:49 in article <Sockets don't work under VC++ 4.0
  15. ?!!>, 'Gavin Williams <gavin@metronet.com>' wrote: 
  16.  
  17.  
  18. >I finally got around to doing a little Windows Sockets programming in VC++
  19.  
  20. >4.0 today and was quickly greeted with an ugly problem--I can't get it to 
  21.  
  22. >create a socket. 
  23. >The CSocket::Create() function consistently failed, and  
  24. >CSocket::GetLastError() returned WSAEPROTOTYPE. I tried running the
  25. CHATTER  
  26. >sample program, and its socket creation failed with the same error. 
  27. >Then I tried tried straight socket API calls (as opposed to using the
  28. CSocket  
  29. >or CAsyncSocket classes). The "socket" function also failed with the  
  30. >WSAEPROTOTYPE error. 
  31. >Finally, I tried some simple sockets code in VC++ 1.52c and VC++ 2.2. The 
  32.  
  33. >code *worked* in both cases. The *exact same code* works fine when
  34. compiled  
  35. >with 2.2 but fails when compiled with 4.0. 
  36.  
  37. I haven't used the MFC classes, but raw winsock API works just fine for 
  38. me.  I started with 2.2 and now using 4.0 with equal success. 
  39.  
  40. >Here's a sample of my test code: 
  41. >WSADATA wsadata; 
  42. >WSAStartup( 0x0101, &wsadata ); 
  43.  
  44. You really should capture and test the return code from WSAStartup -- 
  45. although it's never failed for me so it may be a moot point. 
  46.  
  47. >SOCKET sock; 
  48. >if( INVALID_SOCKET == (sock = socket( PF_INET, SOCK_STREAM, 0 )) ) 
  49.  
  50. Hmm, I use AF_INET -- didn't immediately find the docs on this but 
  51. PF_INET is specified in the 16-bit winsock 1.1 specs.  Try AF_INET. 
  52.  
  53. >    { 
  54. >    int i = WSAGetLastError(); 
  55. >    } 
  56. >WSACleanup(); 
  57. >Two other tidbits:  I'm running NT 3.51, and Microsoft's knowledge base  
  58. >contained nothing about this problem. 
  59. Right.  I know I have the documentation on winsock 2.0 on one of my 
  60. MSDN CD's but can't find it right now.  Oct 95 CD still has version 
  61. 1.1 reference with some paragraphs under the win32 sdk which don't 
  62. help much. 
  63.  
  64. -- 
  65. Pete Grant 
  66. Kalevi, Inc. 
  67. Object Oriented Software Development
  68.